from django.db import models

from apps.vadmin.op_drf.models import CoreModel


class UserCheckoutReport(models.Model):
    assigned_to_id = models.IntegerField(primary_key=True,null=False)
    name = models.CharField(max_length=256,null=True)
    mobile = models.CharField(max_length=20,null=True)
    email = models.CharField(max_length=128,null=True)
    dept_id = models.IntegerField(null=True)
    deptname = models.CharField(max_length=128,null=True)
    asset_num = models.IntegerField(null=True,default=0)
    accessory_num = models.IntegerField(null=True,default=0)
    license_num = models.IntegerField(null=True,default=0)
    consumable_num = models.IntegerField(null=True,default=0)

    class Meta:
        managed = False
        db_table = 'v_usercheckout_report'

class AssetStatusReport(models.Model):
    status = models.CharField(null=False,max_length=32,primary_key=True,verbose_name="状态")
    num = models.IntegerField(null=True,default=0,verbose_name="数量")

    class Meta:
        managed = False
        db_table = 'v_assetstatus_report'


class CategoryTotalReport(models.Model):
    category_id = models.IntegerField(primary_key=True,null=False,verbose_name="分类ID")
    name = models.CharField(max_length=256,null=True,verbose_name="分类名称")
    category_type = models.CharField(max_length=33,null=True,verbose_name="类型")
    asset_num = models.IntegerField(null=True,default=0,verbose_name="资产数量")
    component_num = models.IntegerField(null=True,default=0,verbose_name="组件数量")
    accessory_num = models.IntegerField(null=True,default=0,verbose_name="附属品数量")
    license_num = models.IntegerField(null=True,default=0,verbose_name="软件授权数量")
    consumable_num = models.IntegerField(null=True,default=0,verbose_name="消耗品数量")


    class Meta:
        managed = False
        db_table = 'v_categorytotal_report'

class AssetNowCheckoutReport(models.Model):
    record_id = models.IntegerField(primary_key=True,null=False,verbose_name="分类ID")
    asset_type= models.CharField(max_length=32,null=True,verbose_name="资产类型")
    asset_id = models.IntegerField(null=False,verbose_name="对应资产类型下的ID")
    asset_name = models.CharField(max_length=256,null=True,verbose_name="资产名称")
    assigned_type = models.CharField(max_length=32,null=True,verbose_name="借出类型")
    assigned_to_id = models.IntegerField(null=False,verbose_name="借出给谁的id")
    assigned_to_name = models.CharField(max_length=256,null=True,verbose_name="借给谁的名称")
    serial = models.CharField(max_length=256,null=True,verbose_name="序列号")
    qty = models.IntegerField(null=True,default=0,verbose_name="借出数量")
    purchase_cost = models.DecimalField(max_digits=20,decimal_places=2,null=True,verbose_name="采购价格")
    create_datetime = models.DateTimeField(null=True,verbose_name="创建时间")
    notes = models.CharField(max_length=256,null=True,verbose_name="备注")

    class Meta:
        managed = False
        db_table = 'v_asset_now_checkout'
        ordering = ['-create_datetime']
